﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using ArtClub.Model;
using ArtClub.Controller;

using MAuction = ArtClub.Model.Auction;

namespace UI
{
	/// <summary>
	/// Interaction logic for CreateAuction.xaml
	/// </summary>
	public partial class CreateAuction : UserControl
	{
		private IArtCtr artCtr = new ArtCtr();
		private IAuctionCtr auctionCtr = new AuctionCtr();

		public CreateAuction()
		{
			InitializeComponent();

			PopulateListArt();
		}

		public void PopulateListArt()
		{
			ArtComboBox.ItemsSource = artCtr.ListArts();
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
			MAuction a = new MAuction()
			{
				Sold = false,
				AuctionItem = (Art)ArtComboBox.SelectedItem
			};

			try
			{
				auctionCtr.Create(a);

				MessageBox.Show("Auction created!");

			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}

            //grim kode
            Auction an = new Auction();
            an.UpdateAuctionList();
		}

	}
}
